The present invention relates to a publish/subscribe (Pub/Sub) system in a computer network environment, and more specifically, to a method and system for retrieving messages in order in a publish/subscribe system in a distributed computer network environment.
Nowadays message publish/subscribe systems have become one of important ways for computer network users to retrieve network information. In a publish/subscribe system, subscribers select message sources of interest according to their own demands. Once a publisher publishes a message, the message would be retrieved by subscribers.
With the wide application of the distributed computer network environment, current publish/subscribe systems mainly employ two modes: a mode of pushing messages proactively and a mode of subscribers retrieving messages proactively. In the mode of pushing messages proactively, messages published by a publisher are sent to a plurality of distributed message transit servers (the publisher has no idea as to each message is sent to which specific transit server), and then the message transit servers push the messages to subscribers; this mode is highly demanding on message transit servers. In the mode of subscribers retrieving messages proactively, message transit servers are not responsible for pushing messages, but subscribers proactively retrieve from the message transit servers the messages to which they have subscribed; this mode may reduce resource consumption at the server side.
Messages published in publish/subscribe systems are subjected to order requirements. For example, regarding message publish/subscribe systems of real-time stock quotations, it should be ensured that messages received by subscribers are in strict time order. For another example, in message publish/subscribe systems of football match live broadcasts, receipt of messages should also be in strict time order. As a plurality of publishers might exist, it cannot be ensured that these publishers coordinately publish messages in strict order; further, it cannot be ensured that messages first published first arrive at message transit servers; thus, it is possible that messages with later timestamps first arrive at subscribers.
For publish/subscribe systems in the mode of pushing messages proactively, timestamps of publishing messages may be set in message transit servers, and the message transit servers push messages to subscribers in correct order. In this case, however, there is a heavy dependence on message transit servers; that is, not only the server side needs to understand order requirements as agreed upon between publishers and subscribers, but also messages distributed on multiple distributed servers need to be ordered and proactively pushed to thousands of subscribers. In the meanwhile, even if messages are pushed in correct order, it still cannot be ensured that subscribers receive all messages in correct order.
In publish/subscribe systems where subscribers retrieve messages proactively, there is no technical solution capable of ensuring subscribers receive messages in correct order.